//
// Thread.cpp for  in /home/lund/Projets/plazza
// 
// Made by florian dewulf
// Login   <dewulf_f@epitech.net>
// 
// Started on  Sun Apr 14 22:16:39 2013 florian dewulf
// Last update Mon Apr 15 20:40:04 2013 florian dewulf
//

#include	"Thread.hpp"

Thread::Thread() : _arg(NULL), _retval(NULL), _error(false)
{
}

Thread::~Thread()
{
}

void	Thread::create(void *(*func)(void *))
{
  if (pthread_create(&(this->_thread), NULL, func, this->_arg))
    this->_error = true;
}

void	Thread::join()
{
  if (pthread_join(this->_thread, this->_retval))
    this->_error = true;
}

pthread_t	Thread::getThread() const
{
  return this->_thread;
}

void		*Thread::getArg() const
{
  return this->_arg;
}

void		**Thread::getRetval() const
{
  return this->_retval;
}

bool		Thread::getError() const
{
  return this->_error;
}

void		Thread::setThread(pthread_t thread)
{
  this->_thread = thread;
}

void		Thread::setArg(void *ptr)
{
  this->_arg = ptr;
}

void		Thread::setRetval(void **ptr)
{
  this->_retval = ptr;
}

void		Thread::setError(bool booleen)
{
  this->_error = booleen;
}
